import axios from 'axios'
// import Url from '@/service/url'

const ACTION_REGISTER = 'register'
const ACTION_RESET = 'reset'

export default {

  resetPassword ({username, mobile, password, code}) {
    let url = '/user/password'
    let data = { username, mobile, password, code }
    return new Promise((resolve, reject) => {
      axios.post(url, data, {
        params: {
        }
      })
      .then(res => {
        resolve(res.data)
      })
      .catch(error => {
        reject(error)
      })
    })
  },

  getRegCode (mobile) {
    return this.getSmsCode(mobile, ACTION_REGISTER)
  },
  getResetCode (mobile) {
    return this.getSmsCode(mobile, ACTION_RESET)
  },

  getUser (username) {
    let url = `/user/${username}`
    return new Promise((resolve, reject) => {
      axios.get(url, {
      })
      .then(res => {
        resolve(res.data)
      })
      .catch(error => {
        reject(error)
      })
    })
  },
  getEvent (id) {
    let url = `/event/${id}`
    return new Promise((resolve, reject) => {
      axios.get(url, {
      })
      .then(res => {
        resolve(res.data)
      })
      .catch(error => {
        reject(error)
      })
    })
  }
}
